<template>
  <van-nav-bar title="详情" left-text="" left-arrow @click-left="
    () => {
      $router.push('/');
    }
  " fixed />
  <div style="height: 45px"></div>
  <div v-html="data.goods_introduce"></div>
  <van-action-bar>
    <van-action-bar-icon icon="chat-o" text="客服" color="#ee0a24" />
    <van-action-bar-icon icon="cart-o" text="购物车" />
    <van-action-bar-icon icon="star" text="已收藏" color="#ff5000" />
    <van-action-bar-button type="warning" text="加入购物车" @click="addCart" />
    <van-action-bar-button type="danger" text="立即购买" />
  </van-action-bar>
</template>

<script setup>
import { getDetailApi } from "@/api/api";
import { ref } from "vue";
import { useRoute, useRouter } from "vue-router";

const route = useRoute();
const router = useRouter();
const { goods_id } = route.params;
const data = ref({});
getDetailApi(goods_id).then((res) => {
  data.value = res.data.message;
});

import { useCartsStore } from "@/stores/carts.js";
const store = useCartsStore();
const addCart = () => {
  store.piniaAddCarts(data, goods_id);
  router.push("/home/cart");
};
</script>

<style></style>
